//
//  RootViewController.m
//  UI1_View_Label课后作业2
//
//  Created by dllo on 15/11/7.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController


// 6plus: 414 x 736

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor purpleColor];
    for (NSInteger i = 0; i < 10; i++) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20 * i, 30 * i, 414 - 40 - (40 * i) , 736 - 60 - 60 * i)];
        [self.view addSubview:view];
        [view release];
        [[self.view.subviews objectAtIndex:i] setBackgroundColor:[UIColor colorWithRed:(arc4random() % 256) / 255.0 green:(arc4random() % 256) / 255.0 blue:(arc4random() % 256) / 255.0 alpha:1.0]];
    }
    
    
    // 计时器
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
    
    
}

- (void)timerAction
{
    UIView *temp = [[UIView alloc] init];
    temp.backgroundColor = [[self.view.subviews objectAtIndex:0] backgroundColor];
    
    for (NSInteger i = 0; i < 9; i++) {
        [[self.view.subviews objectAtIndex:i] setBackgroundColor:[[self.view.subviews objectAtIndex:i + 1] backgroundColor ]];
     
    }
[[self.view.subviews objectAtIndex:9] setBackgroundColor:temp.backgroundColor];
    
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
